package lagou.MapTest.CollectionTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

public class MapAdd {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        System.out.println("这个集合里面有什么"+c1);
        boolean b1 = c1.add(12);
        boolean b2 = c1.add(new Person("我的世界",20));
        System.out.println("成功了吗"+b1);
        System.out.println("之后是："+c1);
        System.out.println("--------------------------------------------");
        Collection c2 = new ArrayList();
        c2.add(1);
        c2.add(2);
        c2.add(3);
        c1.addAll(c2);
        System.out.println(c1);

        System.out.println("--------------------------------------------");
        System.out.println("c2中有没有4"+c2.contains(Integer.valueOf(4)));
        System.out.println("c2中有没有3"+c2.contains(3));//工作原理：如果直接e==3为false,那么就要调用3.equals(e)了
        System.out.println("--------------------------------------------");
        System.out.println(c1);
        Collection c3 = new ArrayList();
        c3.add(3);
        System.out.println(c3);
        b1 = c1.containsAll(c3);
        System.out.println(b1);
        c3.add("five");
        b1 = c1.containsAll(c3);
        System.out.println(b1);
        System.out.println("--------------------------------------------");
        System.out.println(b1+"发生改变了吗");
//        b1 = c2.retainAll(c1);
//        System.out.println(c2+""+c1);
//        System.out.println(b1+"发生改变了吗");
        System.out.println(c2);
        b1 = c2.remove(1);
        System.out.println(b1+"删除成功了吗"+c2);
        int a = c2.size();
        System.out.println("c2的长度是多少"+a);
        System.out.println("c2是否为空："+(c2.isEmpty() ? "空了" : "没空"));
        Object[] arr = c2.toArray();
        System.out.println("转换后的"+ Arrays.toString(arr));
    }
}
